package com.ruoyi.user.api.factory;

import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.web.page.TableDataInfo;
import com.ruoyi.user.api.RemoteCarService;
import com.ruoyi.user.api.domain.CheCar;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.cloud.openfeign.FallbackFactory;
import org.springframework.stereotype.Component;

/**
 * 用户服务降级处理
 *
 * @author ruoyi
 */
@Component
public class RemoteCarFallbackFactory<R> implements FallbackFactory<RemoteCarService>
{
    private static final Logger log = LoggerFactory.getLogger(RemoteCarFallbackFactory.class);

    @Override
    public RemoteCarService create(Throwable throwable)
    {
        log.error("车辆服务调用失败:{}", throwable.getMessage());
        return new RemoteCarService() {
            @Override
            public AjaxResult getInfo(Long id, String source) {
                return AjaxResult.error("获取车辆信息失败:" + throwable.getMessage());
            }

            @Override
            public AjaxResult findByIdIn(Long[] ids, String source) {
                return AjaxResult.error("获取车辆信息失败:" + throwable.getMessage());
            }

            @Override
            public TableDataInfo list(CheCar cheCar) {
                return null;
            }

            @Override
            public AjaxResult listbychepai(String chepai) {
                return null;
            }
        };
    }
}
